
#ifndef BQUEUE_H_
#define BQUEUE_H_
#include <pthread.h>

namespace blueberry
{
			/*Memory allocation and deallocation for the data item for BQueueContainer must be done externally
			 * Casting or inheritance is up to the developer
			 */
			class BQueueContainer
			{
			public:
				BQueueContainer( void *);//Params - pointer to relevant data item
				BQueueContainer();
				void * p_Data;
				BQueueContainer* p_Next;
			};
			class BQueue
			{
			public:
				BQueueContainer * p_Head, * p_Tail;
				BQueue();//Creates an empty queue
				void AddtoQueue( BQueueContainer *);//Params - pointer to the BQueueContainer which should be added to the queue tail
			};
			class BQueueHolder
			{
			public:
				BQueueHolder();//To initialize all the members
				~BQueueHolder();
				void AddtoOwnersQueue( BQueueContainer* );//Params - pointer to the BQueueContainer which should be passed from current thread to another thread
				void AddtoOwnersQueueWithLock( BQueueContainer* );
				BQueueContainer* GetFromForeignQueue();//To get from foreign queue
				//Transfer methods
				void TransferToCommonQueue();//Should be run within the host thread
				void TransferFromCommonQueue();//Should be run within the foreign thread
			public:
				BQueue * p_OwnersQueue, * p_CommonQueue, * p_ForeignQueue;
				pthread_mutex_t mut_Lock;

			};
}
#endif /* BQUEUE_H_ */
